package com.rota;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.HashMap;

public class Rota_Tela1 extends Activity{
  private static final int ADDCONTACT = 1;
  private HashMap<String, String> item;
  private ListView list;
  private ArrayList<HashMap<String, String>> lista;

  public void onCreate(Bundle paramBundle){
    super.onCreate(paramBundle);
    setContentView(R.layout.rota_tela1);
    
    //Configurando a ListView  
    //Cria a lista com HASH
    lista = new ArrayList<HashMap<String,String>>();
    
  //Hash com os valores
    item = new HashMap<String,String>();
	item.put("nome","Nome");
    item.put("valor","Rota");
    lista.add(item);
    addListView(list);
    
    
    Button btnova = (Button)findViewById(R.id.bt1);
    
    //acao do botao
    btnova.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
		
			Intent novarota= new Intent("Rota_Tela1_NovaRota");
			startActivity(novarota);

		}
	});
  }


//
//  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
//  {
//    if (paramIntent != null)
//    {
//      HashMap localHashMap1 = new HashMap();
//      this.item = localHashMap1;
//      HashMap localHashMap2 = this.item;
//      String str1 = paramIntent.getStringExtra("nomerota");
//      Object localObject1 = localHashMap2.put("nome", str1);
//      HashMap localHashMap3 = this.item;
//      String str2 = paramIntent.getStringExtra("rota");
//      Object localObject2 = localHashMap3.put("valor", str2);
//      ArrayList localArrayList = this.lista;
//      HashMap localHashMap4 = this.item;
//      boolean bool = localArrayList.add(localHashMap4);
//      ListView localListView = this.list;
//      addListView(localListView);
//      StringBuilder localStringBuilder = new StringBuilder();
//      String str3 = paramIntent.getStringExtra("msg");
//      String str4 = str3;
//      Toast.makeText(this, str4, 0).show();
//    }
//  }
//
  public void addListView(ListView list){
	
	  // create the grid item mapping
	  String[] from = new String[] {"nome", "valor"};
      int[] to = new int[] {R.id.CampoDescricao,R.id.CampoValor};

      SimpleAdapter adapter = new SimpleAdapter(this, lista, R.layout.rota_tela1_rotas, from, to);
      list.setAdapter(adapter);

  }
}